﻿<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
    <title>智税-后台管理中心</title>
    <link rel="stylesheet" href="Content/src/css/layui.css" media="all">
    
</head>
<body>
<div class="layui-tab layui-tab-brief main-tab-container ">
    <div class="layui-tab-content">
        <button class="layui-btn layui-btn-normal layui-btn-small demo" data-type="add"><i class="layui-icon">&#xe605;</i> 审 批 </button>
        <button class="layui-btn layui-btn-danger layui-btn-small" lay-submit lay-filter="delete"><i class="layui-icon">&#xe640;</i> 删 除 </button>
    </div>
    <div class="layui-form layui-tab-content">
      <table class="layui-table">
        <colgroup>
          <col width="80">
        </colgroup>
        <thead>
          <tr>
            <th><input name="checkAll" lay-skin="primary" type="checkbox" lay-filter="checkAll" ></th>
            <th>序号</th>
            <th>街办</th>
            <th>社区</th>
            <th>楼宇</th>
            <th>单元</th>
            <th>房号</th>
            <th>审核人</th>
            <th>审核时间</th>
            <th>备注</th>
            <th>审批状态</th>
            <th>审批意见</th>
          </tr> 
        </thead>
        <tbody id="showNewList">

        </tbody>
      </table>
    </div>
</div>

<!-- Mode -->
<div id="add_edit" style="display: none; padding-right: 20px; padding-top: 20px;">
    <form class="layui-form">
        <div class="layui-form-item">
            <label class="layui-form-label">审批结果：</label>
            <div class="layui-input-block">
                <input type="radio" name="apply" value="1" title="通过" checked>
                <input type="radio" name="apply" value="2" title="拒绝">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">审批意见：</label>
            <div class="layui-input-block">
                <textarea class="layui-textarea" name="content" id="Info_Mation"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"> </label>
            <div class="layui-input-block">
                <p class="layui-form-mid layui-word-aux">注：如果房屋信息没有在综合治税系统中存在，请登陆综合治水系统添加房屋信息，并驳回推送请求，提醒用户重新提交。<p>
            </div>
        </div>
        <div class="layui-form-item" style="text-align: right;">
            <div class="layui-btn layui-btn-normal" lay-submit lay-filter="btnSubmit">提 交</div>
        </div>
    </form>
</div>

<script type="text/javascript" src="Content/src/layui.js"></script>
<script src="Content/js/zor_base.js"></script>
<script type="text/javascript">
    layui.use(['element', 'layer', 'form', 'layedit'], function () {
        var element = layui.element()
        , jq = layui.jquery
        , form = layui.form()
        , layedit = layui.layedit
        , laypage = layui.laypage;



        //加载推送信息
        jq(document).ready(function () {
            if (localStorage.getItem("username") == "" || localStorage.getItem("username") == null) {
                window.location.href = "login.html";
            } else {
                var Apply = {
                    Dt_ParentId: localStorage.getItem("dtparentId")
                };
                loading = layer.load();
                jq.ajax({
                    url: '/api/PropertyInfo/PushMegList',
                    type: 'POST',
                    contentType: "application/json",
                    dataType: "json",
                    data: JSON.stringify(Apply),
                    success: function (data) {
                        var html = '';
                        var accordionMenu = data;
                        jq.each(accordionMenu, function (i) {
                            html += "<tr>";
                            html += "<td><input name='' lay-skin='primary' type='checkbox' lay-filter='checkOne' role-id='" + accordionMenu[i].Property_Id + "' role-apply='" + accordionMenu[i].AuditStatus + "'></td>";
                            html += "<td>" + (i + 1) + "</td>";
                            html += "<td>" + accordionMenu[i].Dt_ParentName + "</td>";
                            html += "<td>" + accordionMenu[i].Dt_Name + "</td>";
                            html += "<td>" + accordionMenu[i].Bd_Name + "</td>";
                            html += "<td>" + accordionMenu[i].Uim_Name + "</td>";
                            html += "<td>" + accordionMenu[i].Hs_Number + "</td>";
                            html += "<td>" + (accordionMenu[i].AuditUserName == null ? " " : accordionMenu[i].AuditUserName) + "</td>";
                            html += "<td>" + (accordionMenu[i].AuditTime == '0001-01-01T00:00:00' ? " " : accordionMenu[i].AuditTime) + "</td>";
                            html += "<td>" + (accordionMenu[i].Address == null ? "/" : accordionMenu[i].Address) + "</td>";
                            if (accordionMenu[i].AuditStatus == 0)
                                html += "<td>未审核</td>";
                            else if (accordionMenu[i].AuditStatus == 1)
                                html += "<td>审核通过</td>";
                            else
                                html += "<td>驳回</td>";
                            html += "<td>" + (accordionMenu[i].AuditMeg == null ? "/" : accordionMenu[i].AuditMeg) + "</td>";
                            html += "</tr>";
                        });

                        jq('#showNewList').empty().append(html);
                        form.render('checkbox');
                        layer.close(loading);
                    }
                })
            }
        });


        //监听提交- 删除
        form.on('submit(delete)', function (data) {
            //判断是否有选项
            var ary = check(jq);
            if (ary.length == 0) {
                layer.msg('请选择要删除的数据！');
                return false;
            }
            if (ary[0].AuditStatus != "2") {
                layer.msg('只能删除驳回的数据！');
                return false;
            }

            layer.confirm("确认删除吗", { icon: 2, btn: ['确定', '取消'] }, function (index, layero) {
                jq.ajax({
                    type: 'post',
                    url: '/api/PropertyInfo/DelPushMeg',
                    contentType: "application/json",
                    data: JSON.stringify({ 'ids': ary }),
                    dataType: "json",
                    success: function (data) {
                        if (data.AnswerType == 1) {
                            layer.close(loading);
                        }
                        layer.msg(data.AnswerMeg, function () {
                            location.reload();
                            return false;
                        });
                        Replace();
                    }
                });
            });
        });

        //全选
        form.on('checkbox(checkAll)', function (data) {
            if (data.elem.checked) {
                jq("input[type='checkbox']").prop('checked', true);
            } else {
                jq("input[type='checkbox']").prop('checked', false);
            }
            form.render('checkbox');
        });


        //单选
        form.on('checkbox(checkOne)', function (data) {
            var is_check = true;
            if (data.elem.checked) {
                jq("input[lay-filter='checkOne']").each(function () {
                    if (!jq(this).prop('checked')) { is_check = false; }
                });
                if (is_check) {
                    jq("input[lay-filter='checkAll']").prop('checked', true);
                }
            } else {
                jq("input[lay-filter='checkAll']").prop('checked', false);
            }
            form.render('checkbox');
        });


        //显示弹出框 - 增加、修改
        jq('.demo').on('click', function () {

            var ary = check(jq);
            if (ary.length == 0 || ary.length > 1) {
                layer.msg('必须选择一行数据！');
                return;
            }

            layer.open({
                title: "审批",
                type: 1,
                skin: 'layui-layer-rim',
                area: ['700px', '360px'],
                content: jq('#add_edit')
            });

        });


        //提交新增、编辑
        form.on('submit(btnSubmit)', function (data) {
            var ary = check(jq);

            var Apply = {
                Property_Id: ary[0].Property_Id,
                AuditStatus: jq('input:radio[name="apply"]:checked').val(),
                AuditMeg: jq('#Info_Mation').val(),
                AuditUserId: localStorage.getItem("userid")
            };

            loading = layer.load();

            jq.ajax({
                url: '/api/PropertyInfo/ApplyPushMeg',
                type: 'POST',
                contentType: "application/json",
                dataType: "json",
                data: JSON.stringify(Apply),
                success: function (data) {
                    if (data.AnswerType == 1) {
                        layer.close(loading);
                    }
                    layer.msg(data.AnswerMeg, function () {
                        Replace();
                    });
                }
            });
            
        });


        //返回 选择行的值
        function check() {
            var ary = new Array();
            jq("input[lay-filter='checkOne']").each(function () {
                if (jq(this).prop('checked')) {
                    var ckindex = jq(this).attr('role-id');
                    var ckapply = jq(this).attr('role-apply');
                    ary.push({ Property_Id: ckindex, AuditStatus: ckapply });
                }
            });
            return ary;
        }



    })
</script>

</body>
</html>